#include <iostream>
using namespace std;

const int N = 10010;

int n;
int a[N],b[N];

int check(int x){
	b[1] = x;
	for(int i = 2;i <= n + 1;i++){
		b[i] = a[i - 1] - b[i - 1] - b[i - 2];
		if(b[i] < 0||b[i] > 1) return 0;
	}
	if(b[n + 1] == 0) return 1;
	return 0;
}

int main(){
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
	}
	
	int ret = 0;
	
	ret += check(0);
	ret += check(1);
	
	cout << ret << endl;
	
	return 0;
}
